import { useState, useEffect } from "react";
import { getQualifications } from "../../api/goods";
import { Table, Button, Space, Tag,Image } from "antd";
import { useLocation } from 'react-router-dom';
const Qualifications = () => {
    const [zizhi, setZizhi] = useState([]);
    const location = useLocation();
    const ziZHiData = async () => {
        await getQualifications({
            id: location.pathname.slice(17),
        }).then((res) => {
            if (res.result === 0) {
                setZizhi(res.data.data);

            }
        });

    };
    useEffect(() => {
        ziZHiData();
    }, []);
    const columns = [
        {
            title: "序号",
            render: (text, record, index) => `${index + 1}`
        },
        {
            title: "资质名称",
            dataIndex: "name",
            key: "name",
        },
        {
            title: "图片",
            dataIndex: "orderCount",
            key: "orderCount",
            render: (text) => {
                <Image width={50}
                    src={text}/>
            }
        },
        {
            title: "添加时间",
            dataIndex: "time",
            key: "time",
            render: (_, record) => (
                <Tag color="default">{record.orderMoney}</Tag>
            )
        },
        {
            title: '状态',
            dataIndex: "isDel",
            key: 'isDel',
            render: (_, record) => (
                <Tag color={record.isDel===1?'red':'success'}>{record.isDel===1?'已删除':'正常'}</Tag>
            )
        },
        {
            title: '删除时间',
            dataIndex: 'deleteTime',
            key: 'deleteTime',
        },



        {
            title: '操作',
            key: 'operation',
            fixed: 'right',
            width: 200,
            render: (record) => (
                <Space size="middle">

                    {record.isActive === 0 ? (
                        <Button danger  >删除</Button>
                    ) : null}
                </Space>
            ),
        },

    ];
    return (
        <div>
            <div className="table">
                <Table
                    columns={columns}
                    dataSource={zizhi}
                    bordered
                    pagination={false}
                />
            </div>
        </div>
    )
}

export default Qualifications;